<?php

/*
	[BuyPg] (C) 2010-2011 Buypg
	$Id: NbSiteAction.class.php 2011-10-10 10:58:19 wufujun $
 */
if (!defined('THINK_PATH')) {
	exit('Access Denied');
}

class NbSiteAction extends BpAction{
	function _filter(&$map){
		$map['site_name'] = array('like',"%".$_POST['site_name']."%");
	}
	
	//赋值可用分类
	public function _before_add(){
		$NbClassModel = D('NbClass');
		$NbClass = $NbClassModel->select();
		$this->assign('NbClass',$NbClass);
		
		$ZhuanTiModel = D('Zhuanti');
		$ZhuanTi = $ZhuanTiModel->where('flag = 1')->select();
		$this->assign('ZhuanTi',$ZhuanTi);
	}
	
	//赋值可用分类
	public function _before_edit(){
		$NbClassModel = D('NbClass');
		$NbClass = $NbClassModel->select();
		$this->assign('NbClass',$NbClass);
		
		$ZhuanTiModel = D('Zhuanti');
		$ZhuanTi = $ZhuanTiModel->where('flag = 1')->select();
		$this->assign('ZhuanTi',$ZhuanTi);
	}
	
	//插入操作
	public function insert() {
		// 创建数据对象
		$Website	 =	 D("NbSite");
		if(!$Website->create()) {
			$this->error($Website->getError());
		}else{
			// 写入网站数据
			if($result	 =	 $Website->add()) {
				$this->success('网站添加成功！');
			}else{
				$this->error('网站添加失败！');
			}
		}
	}
}
?>
